package cn.sunxyz.code.ram;


import java.util.HashMap;
import java.util.Map;

/**
 * Created by yangrd on 2017/3/20.
 */
public class RAM implements Stack<boolean[]> {

    private Map<Long, boolean[]> addressRAM = new HashMap<>();

    private Long address = 0L;

    public boolean[] get(Long Address) {
        return addressRAM.get(addressRAM);
    }

    public void set(Long address, boolean[] b_s) {
        addressRAM.put(address, b_s);
    }

    @Override
    public boolean[] pop() {
        if (address == 0) {
            throw new StackOverflowError("下标越界");
        }
        return addressRAM.get(--address);
    }

    @Override
    public void push(boolean[] booleans) {
        if (booleans.length != 8) {
            throw new StackOverflowError("");
        }
        addressRAM.put(++address, booleans);
    }

    public Long getAddress() {
        return address;
    }
}
